package com.itheima.sort;

public class BinarySearch {
    public static void main(String[] args) {

        int[] arr = {1,2,3,4,5,6,7,8,9};
        int left = 0;
        int right = arr.length-1;
        int number = 7;
        while (right>=left){
            int mid = (left + right) >> 1;
            if (arr[mid]>number){
                right = mid-1;
                continue;
            }
            if (arr[mid]<number){
                left = left+1;
                continue;
            }else {
                System.out.println(mid);
                break;
            }
        }
    }
}
